
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>故障提交页面</title>
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../css/common.css"/>
		<style>
			body {
			}
			#goto-history {
				margin-right: 15px;
			}
			.icon-history{
				background-size:22px 19px;
			}
			#btn-commit{
				font-size:16px;
			}
		</style>
	</head>
	<body>
		<header class="top-header">
			<div class="top-nav-content flex-container flex-between flex-center-v">
				<div class="flex-item">
					<div id="btn-back" class="icon-arrow-left"></div>
				</div>
				<div>
					故障上报
				</div>
				<div class="flex-item flex-container flex-between flex-center-v">
					<div></div>
					<div class="flex-container flex-center-v">
						<div id="goto-history" class="icon-normal icon-history"></div>
						<div id="btn-commit">
							提交
						</div>
					</div>
				</div>
			</div>
		</header>
	</body>
	<script type="text/javascript" src="../script/api.js"></script>
	<script type="text/javascript" src="../script/common.js"></script>
	<script type="text/javascript">
		//用户身份
		var mUserLimit;
		apiready = function() {
			//适配iOS7+，Android4.4+状态栏沉浸式效果，详见config文档statusBarAppearance字段
			$api.fixStatusBar($api.dom('header'));
			initData();
			initView();
			openFm();
		};
		function initData() {
			mUserLimit = $api.getStorage(MyCom.key_userlimit);
		}

		function initView() {
			var doc = document;
			var btnExit = doc.getElementById('btn-back');
			var btnGotoH = doc.getElementById('goto-history');
			var btnCommit = doc.getElementById('btn-commit');
			btnCommit.onclick = function() {
				triggerCommitCpListener();
			}
			btnGotoH.onclick = function() {
				gotoHistory();
			}
			btnExit.onclick = function() {
				backMethod();
			}
			setBackListener();
		}

		/**
		 * 打开此页面的frame
		 */
		function openFm() {

			api.openFrame({
				name : 'complaint_comit_frame',
				url : './complaint_comit_frame.html',
				rect : {
					x : 0,
					y : getFrameY(),
					w : api.winWidth,
					h : 'auto'
				},
				pageParam : {
					'top' : $api.dom('header').offsetHeight
				}
			});
		}

		function getFrameY(){
			var frameheigh = $api.dom('header').offsetHeight;
			var systemType = api.systemType;
			if(api.systemType === 'ios'){
					var systemVersion = api.systemVersion;
					if(parseFloat(systemVersion) >= 11.0){
						frameheigh = frameheigh + 20;
					}
					return frameheigh;
			}
			return frameheigh;
		}


		/**
		 * 跳转到“历史报障”页面
		 */
		function gotoHistory() {
			api.openWin({
				name : 'complaint_history',
				url : './complaint_history.html',
				slidBackEnabled : false
			});
		}

		/**
		 * 对此页面的虚拟返回键，做处理
		 */
		function setBackListener() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				backMethod() ;
			});
		}

		/**
		 * 返回上一页的处理方法
		 */
		function backMethod() {
			//如果mUserLimit==0，是普通用户,就直接关闭widget，反之返回上一页
			if (mUserLimit == 0) {
				MyCom.closeThisWgt();
			} else {
				api.closeWin({
                });
			}
		}

		/**
		 * 触发“提交报障”的监听
		 */
		function triggerCommitCpListener() {
			api.sendEvent({
				name : 'CommitCpListener'
			});
		}
	</script>
</html>
